package com.aletto.general_store.presenters;

import androidx.recyclerview.widget.RecyclerView;

import com.aletto.general_store.data.DataRepository;
import com.aletto.general_store.data.model.ConsumerOrder;
import com.aletto.general_store.data.model.PageResponse;
import com.aletto.general_store.data.model.ServiceOrder;
import com.aletto.general_store.presenters.core.SimplePageTemplate;
import com.aletto.general_store.ui.adapters.AppealOrderAdapter;
import com.aletto.general_store.ui.adapters.ConsumerOrderAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.sisyphus.spinach.core.INetPageTask;
import com.sisyphus.spinach.core.model.IPageResponse;
import com.sisyphus.spinach.core.model.IResponse;
import com.sisyphus.spinach.network.presenters.NetPageTask;

import io.reactivex.rxjava3.core.Observable;

public class AppealOrderPageTemplate extends SimplePageTemplate<ServiceOrder> {

    private int type;
    private String keyword;

    public AppealOrderPageTemplate(RecyclerView recyclerView, SmartRefreshLayout refreshLayout) {
        super(recyclerView, refreshLayout);
    }

    public void setParams(int type, String keyword) {
        this.type = type;
        this.keyword = keyword;
    }

    @Override
    public BaseQuickAdapter<ServiceOrder, BaseViewHolder> adapter(RecyclerView recyclerView) {
        return new AppealOrderAdapter();
    }

    @Override
    public INetPageTask.Presenter<ServiceOrder, INetPageTask.View<ServiceOrder>> presenter() {
        return new NetPageTask<>() {
            @Override
            public Observable<? extends IResponse<? extends IPageResponse<ServiceOrder>>> execute(int page) {
                return DataRepository.getInstance().kefuOrderList(page, PageResponse.SIZE, type, keyword);
            }
        };
    }
}

